import { apiService } from './api'
import type { User } from '@/types/api'

// 用户API服务
export const userApi = {
  // 获取所有用户
  async getUsers(): Promise<User[]> {
    return apiService.get<User[]>('/users')
  },

  // 根据ID获取用户
  async getUserById(id: number): Promise<User> {
    return apiService.get<User>(`/users/${id}`)
  },

  // 创建用户
  async createUser(userData: Omit<User, 'id'>): Promise<User> {
    return apiService.post<User>('/users', userData)
  },

  // 更新用户
  async updateUser(id: number, userData: Partial<User>): Promise<User> {
    return apiService.put<User>(`/users/${id}`, userData)
  },

  // 删除用户
  async deleteUser(id: number): Promise<void> {
    return apiService.delete<void>(`/users/${id}`)
  },
}
